package com.smartleanx.module.hrm.service.esign.service.impl;


import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartleanx.module.hrm.dal.mysql.esign.HrmEFolderArchivingMapper;
import com.smartleanx.module.hrm.service.esign.service.HrmEFolderArchivingService;
import com.smartleanx.module.hrm.service.esign.service.HrmEFolderService;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmEFolder;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmEFolderArchiving;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * e签宝文件夹存放的模板Service实现
 *
 * @author xzq
 * @since 2025-07-31 14:12:13
 */
@Service
public class HrmEFolderArchivingServiceImpl extends ServiceImpl<HrmEFolderArchivingMapper, HrmEFolderArchiving> implements HrmEFolderArchivingService {
    @Autowired
    private HrmEFolderService hrmEFolderService;


    @Override
    public List<HrmEFolderArchiving> getFolderListByFolderId(Long folderId) {
        List<HrmEFolder> parentList = hrmEFolderService.getFolderListByFolderId(folderId);

        List<Long> ids = new ArrayList<>();
        if(CollUtil.isNotEmpty(parentList)){
            ids = parentList.stream().map(HrmEFolder::getId).collect(Collectors.toList());
        }
        if(ids == null){
            ids = new ArrayList<>();
        }
        ids.add(folderId);

        return list(new LambdaQueryWrapper<HrmEFolderArchiving>()
        .eq(HrmEFolderArchiving::getDataStatus,1)
        .in(HrmEFolderArchiving::getFolderId,ids));
    }
}
